package com.example.takeoutfood.ui.beha;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;

import com.example.takeoutfood.R;
import com.example.takeoutfood.ui.ShopPriceLayout;

public class ShopPriceBeahavior extends CoordinatorLayout.Behavior<View> {
    public ShopPriceBeahavior() {
    }

    public ShopPriceBeahavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {
        return dependency.getId() == R.id.layout_main;
    }

    @Override
    public boolean onLayoutChild(@NonNull CoordinatorLayout parent, @NonNull View child, int layoutDirection) {
        return super.onLayoutChild(parent, child, layoutDirection);

    }

    @Override
    public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {
        System.out.println("=ependency.getY()=="+dependency.getY());
        if (dependency.getY() > 200 ){
            child.setTranslationY(200);
        }
        return true;
    }
}
